package com.lunatic.assistant.service.impl;

import com.fasterxml.jackson.annotation.JsonClassDescription;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import org.springframework.stereotype.Service;

import java.util.UUID;

@Service
public class WeatherService {


    public Response getWeather(Request request) {
        String weather = "阴天雨天想你的一天。";
        return new Response(String.format("天气：%s, 城市：%s", weather, request.city));
    }

    public Response getTemper(Request request) {
        String temper = "38℃";
        return new Response(String.format("气温：%s, 城市：%s", temper, request.city));
    }

    public Response orderTik(Request request) {
        String orderId = UUID.randomUUID().toString();
        return new Response(String.format("订购成功, 目的城市：%s， 订单号：%s", request.city, orderId));
    }

//    @JsonClassDescription("获取本地天气")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    public record Request(
            //这里的JsonProperty将转换为function的parameters信息, 包括参数名称和参数描述等
            /*
             {
                "orderId": {
                    "type": "string",
                    "description": "订单编号, 比如1001***"
                    },
                "userId": {
                    "type": "string",
                    "description": "用户编号, 比如2001***"
                }
            }
            */
            @JsonProperty(required = true, value = "city") @JsonPropertyDescription("城市，比如北京") String city) {
    }

    public record Response(String description) {
    }
}
